package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.GenTableDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.GenTable;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface GenTableMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    BasicColumn[] selectList = BasicColumn.columnList(tableId, tableName, tableComment, subTableName, subTableFkName, className, tplCategory, packageName, moduleName, businessName, functionName, functionAuthor, genType, genPath, options, createBy, createTime, updateBy, updateTime, remark);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<GenTable> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("GenTableResult")
    Optional<GenTable> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="GenTableResult", value = {
        @Result(column="table_id", property="tableId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="table_name", property="tableName", jdbcType=JdbcType.VARCHAR),
        @Result(column="table_comment", property="tableComment", jdbcType=JdbcType.VARCHAR),
        @Result(column="sub_table_name", property="subTableName", jdbcType=JdbcType.VARCHAR),
        @Result(column="sub_table_fk_name", property="subTableFkName", jdbcType=JdbcType.VARCHAR),
        @Result(column="class_name", property="className", jdbcType=JdbcType.VARCHAR),
        @Result(column="tpl_category", property="tplCategory", jdbcType=JdbcType.VARCHAR),
        @Result(column="package_name", property="packageName", jdbcType=JdbcType.VARCHAR),
        @Result(column="module_name", property="moduleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="business_name", property="businessName", jdbcType=JdbcType.VARCHAR),
        @Result(column="function_name", property="functionName", jdbcType=JdbcType.VARCHAR),
        @Result(column="function_author", property="functionAuthor", jdbcType=JdbcType.VARCHAR),
        @Result(column="gen_type", property="genType", jdbcType=JdbcType.CHAR),
        @Result(column="gen_path", property="genPath", jdbcType=JdbcType.VARCHAR),
        @Result(column="options", property="options", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_by", property="createBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_by", property="updateBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<GenTable> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, genTable, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, genTable, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    default int deleteByPrimaryKey(Long tableId_) {
        return delete(c -> 
            c.where(tableId, isEqualTo(tableId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    default int insert(GenTable record) {
        return MyBatis3Utils.insert(this::insert, record, genTable, c ->
            c.map(tableId).toProperty("tableId")
            .map(tableName).toProperty("tableName")
            .map(tableComment).toProperty("tableComment")
            .map(subTableName).toProperty("subTableName")
            .map(subTableFkName).toProperty("subTableFkName")
            .map(className).toProperty("className")
            .map(tplCategory).toProperty("tplCategory")
            .map(packageName).toProperty("packageName")
            .map(moduleName).toProperty("moduleName")
            .map(businessName).toProperty("businessName")
            .map(functionName).toProperty("functionName")
            .map(functionAuthor).toProperty("functionAuthor")
            .map(genType).toProperty("genType")
            .map(genPath).toProperty("genPath")
            .map(options).toProperty("options")
            .map(createBy).toProperty("createBy")
            .map(createTime).toProperty("createTime")
            .map(updateBy).toProperty("updateBy")
            .map(updateTime).toProperty("updateTime")
            .map(remark).toProperty("remark")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    default int insertSelective(GenTable record) {
        return MyBatis3Utils.insert(this::insert, record, genTable, c ->
            c.map(tableId).toPropertyWhenPresent("tableId", record::getTableId)
            .map(tableName).toPropertyWhenPresent("tableName", record::getTableName)
            .map(tableComment).toPropertyWhenPresent("tableComment", record::getTableComment)
            .map(subTableName).toPropertyWhenPresent("subTableName", record::getSubTableName)
            .map(subTableFkName).toPropertyWhenPresent("subTableFkName", record::getSubTableFkName)
            .map(className).toPropertyWhenPresent("className", record::getClassName)
            .map(tplCategory).toPropertyWhenPresent("tplCategory", record::getTplCategory)
            .map(packageName).toPropertyWhenPresent("packageName", record::getPackageName)
            .map(moduleName).toPropertyWhenPresent("moduleName", record::getModuleName)
            .map(businessName).toPropertyWhenPresent("businessName", record::getBusinessName)
            .map(functionName).toPropertyWhenPresent("functionName", record::getFunctionName)
            .map(functionAuthor).toPropertyWhenPresent("functionAuthor", record::getFunctionAuthor)
            .map(genType).toPropertyWhenPresent("genType", record::getGenType)
            .map(genPath).toPropertyWhenPresent("genPath", record::getGenPath)
            .map(options).toPropertyWhenPresent("options", record::getOptions)
            .map(createBy).toPropertyWhenPresent("createBy", record::getCreateBy)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(updateBy).toPropertyWhenPresent("updateBy", record::getUpdateBy)
            .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    default Optional<GenTable> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, genTable, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.569+08:00", comments="Source Table: gen_table")
    default List<GenTable> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, genTable, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.57+08:00", comments="Source Table: gen_table")
    default List<GenTable> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, genTable, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.57+08:00", comments="Source Table: gen_table")
    default Optional<GenTable> selectByPrimaryKey(Long tableId_) {
        return selectOne(c ->
            c.where(tableId, isEqualTo(tableId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.57+08:00", comments="Source Table: gen_table")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, genTable, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.57+08:00", comments="Source Table: gen_table")
    static UpdateDSL<UpdateModel> updateAllColumns(GenTable record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(tableId).equalTo(record::getTableId)
                .set(tableName).equalTo(record::getTableName)
                .set(tableComment).equalTo(record::getTableComment)
                .set(subTableName).equalTo(record::getSubTableName)
                .set(subTableFkName).equalTo(record::getSubTableFkName)
                .set(className).equalTo(record::getClassName)
                .set(tplCategory).equalTo(record::getTplCategory)
                .set(packageName).equalTo(record::getPackageName)
                .set(moduleName).equalTo(record::getModuleName)
                .set(businessName).equalTo(record::getBusinessName)
                .set(functionName).equalTo(record::getFunctionName)
                .set(functionAuthor).equalTo(record::getFunctionAuthor)
                .set(genType).equalTo(record::getGenType)
                .set(genPath).equalTo(record::getGenPath)
                .set(options).equalTo(record::getOptions)
                .set(createBy).equalTo(record::getCreateBy)
                .set(createTime).equalTo(record::getCreateTime)
                .set(updateBy).equalTo(record::getUpdateBy)
                .set(updateTime).equalTo(record::getUpdateTime)
                .set(remark).equalTo(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.57+08:00", comments="Source Table: gen_table")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(GenTable record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(tableId).equalToWhenPresent(record::getTableId)
                .set(tableName).equalToWhenPresent(record::getTableName)
                .set(tableComment).equalToWhenPresent(record::getTableComment)
                .set(subTableName).equalToWhenPresent(record::getSubTableName)
                .set(subTableFkName).equalToWhenPresent(record::getSubTableFkName)
                .set(className).equalToWhenPresent(record::getClassName)
                .set(tplCategory).equalToWhenPresent(record::getTplCategory)
                .set(packageName).equalToWhenPresent(record::getPackageName)
                .set(moduleName).equalToWhenPresent(record::getModuleName)
                .set(businessName).equalToWhenPresent(record::getBusinessName)
                .set(functionName).equalToWhenPresent(record::getFunctionName)
                .set(functionAuthor).equalToWhenPresent(record::getFunctionAuthor)
                .set(genType).equalToWhenPresent(record::getGenType)
                .set(genPath).equalToWhenPresent(record::getGenPath)
                .set(options).equalToWhenPresent(record::getOptions)
                .set(createBy).equalToWhenPresent(record::getCreateBy)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(updateBy).equalToWhenPresent(record::getUpdateBy)
                .set(updateTime).equalToWhenPresent(record::getUpdateTime)
                .set(remark).equalToWhenPresent(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.57+08:00", comments="Source Table: gen_table")
    default int updateByPrimaryKey(GenTable record) {
        return update(c ->
            c.set(tableName).equalTo(record::getTableName)
            .set(tableComment).equalTo(record::getTableComment)
            .set(subTableName).equalTo(record::getSubTableName)
            .set(subTableFkName).equalTo(record::getSubTableFkName)
            .set(className).equalTo(record::getClassName)
            .set(tplCategory).equalTo(record::getTplCategory)
            .set(packageName).equalTo(record::getPackageName)
            .set(moduleName).equalTo(record::getModuleName)
            .set(businessName).equalTo(record::getBusinessName)
            .set(functionName).equalTo(record::getFunctionName)
            .set(functionAuthor).equalTo(record::getFunctionAuthor)
            .set(genType).equalTo(record::getGenType)
            .set(genPath).equalTo(record::getGenPath)
            .set(options).equalTo(record::getOptions)
            .set(createBy).equalTo(record::getCreateBy)
            .set(createTime).equalTo(record::getCreateTime)
            .set(updateBy).equalTo(record::getUpdateBy)
            .set(updateTime).equalTo(record::getUpdateTime)
            .set(remark).equalTo(record::getRemark)
            .where(tableId, isEqualTo(record::getTableId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.57+08:00", comments="Source Table: gen_table")
    default int updateByPrimaryKeySelective(GenTable record) {
        return update(c ->
            c.set(tableName).equalToWhenPresent(record::getTableName)
            .set(tableComment).equalToWhenPresent(record::getTableComment)
            .set(subTableName).equalToWhenPresent(record::getSubTableName)
            .set(subTableFkName).equalToWhenPresent(record::getSubTableFkName)
            .set(className).equalToWhenPresent(record::getClassName)
            .set(tplCategory).equalToWhenPresent(record::getTplCategory)
            .set(packageName).equalToWhenPresent(record::getPackageName)
            .set(moduleName).equalToWhenPresent(record::getModuleName)
            .set(businessName).equalToWhenPresent(record::getBusinessName)
            .set(functionName).equalToWhenPresent(record::getFunctionName)
            .set(functionAuthor).equalToWhenPresent(record::getFunctionAuthor)
            .set(genType).equalToWhenPresent(record::getGenType)
            .set(genPath).equalToWhenPresent(record::getGenPath)
            .set(options).equalToWhenPresent(record::getOptions)
            .set(createBy).equalToWhenPresent(record::getCreateBy)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(updateBy).equalToWhenPresent(record::getUpdateBy)
            .set(updateTime).equalToWhenPresent(record::getUpdateTime)
            .set(remark).equalToWhenPresent(record::getRemark)
            .where(tableId, isEqualTo(record::getTableId))
        );
    }
}